namespace pos.entity
{
using System;
using System.Data;
using System.Configuration;
using System.Text;
using System.Data.OleDb;
using System.Collections;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Criterion;
/// <summary>
/// t_hsale 的摘要说明
/// </summary>
public class t_hsale:IEntityUtil
{
//   状态值的哈希表 
	private static Hashtable m_enum_specialOffer;
	public static Hashtable  enum_specialOffer
	{
		get{return m_enum_specialOffer;}
	}
	public const int SPECIALYES=11;
	public const int SPECIALNO=10;
//   结算状态值的哈希表 
	private static Hashtable m_enum_settleState;
	public static Hashtable  enum_settleState
	{
		get{return m_enum_settleState;}
	}
	public const int SETTLEYES=1;
	public const int SETTLENO=0;
//   销售类型值的哈希表 
	private static Hashtable m_enum_saleType;
	public static Hashtable  enum_saleType
	{
		get{return m_enum_saleType;}
	}
	public const int DEFAULT=0;
	public const int RETURNED=1;
	public const int LOSS=2;
	//   列名称哈希表 
	private static Hashtable m_colLabels;    	 
	public static Hashtable colLabels//
	{
		get{return m_colLabels;}
	}
	//表字段名称哈希表
	private static ArrayList m_colNames;     
	public static ArrayList  colNames　
	{
		get{return m_colNames;}
	}
	private Hsale __hsale;
	public long seqID  
	{
		get{return __hsale.seqID;}
		set{ __hsale.seqID=value;}
	}
	public long moneySeqID  
	{
		get{return __hsale.moneySeqID;}
		set{ __hsale.moneySeqID=value;}
	}
	public long commoditySeqID  
	{
		get{return __hsale.commoditySeqID;}
		set{ __hsale.commoditySeqID=value;}
	}
	public String commodityID  
	{
		get{return __hsale.commodityID;}
		set{ __hsale.commodityID=value;}
	}
	public String commodityName  
	{
		get{return __hsale.commodityName;}
		set{ __hsale.commodityName=value;}
	}
	public double salePrice  
	{
		get{return __hsale.salePrice;}
		set{ __hsale.salePrice=value;}
	}
	public double saleAmount  
	{
		get{return __hsale.saleAmount;}
		set{ __hsale.saleAmount=value;}
	}
	public double storagePrice  
	{
		get{return __hsale.storagePrice;}
		set{ __hsale.storagePrice=value;}
	}
	public int specialOffer  
	{
		get{return __hsale.specialOffer;}
		set{ __hsale.specialOffer=value;}
	}
	public String userID  
	{
		get{return __hsale.userID;}
		set{ __hsale.userID=value;}
	}
	public long cashboxNO  
	{
		get{return __hsale.cashboxNO;}
		set{ __hsale.cashboxNO=value;}
	}
	public String memberSeqID  
	{
		get{return __hsale.memberSeqID;}
		set{ __hsale.memberSeqID=value;}
	}
	public DateTime saleTime  
	{
		get{return __hsale.saleTime;}
		set{ __hsale.saleTime=value;}
	}
	public int settleState  
	{
		get{return __hsale.settleState;}
		set{ __hsale.settleState=value;}
	}
	public int saleType  
	{
		get{return __hsale.saleType;}
		set{ __hsale.saleType=value;}
	}
	private static  HsaleDao dao=(HsaleDao)SpringContext.Context.GetObject("HsaleDao");
	public static HsaleDao DAO
	{
		get{return dao;}
		
	}
	
	public t_hsale()
	{
		__hsale=new Hsale();
	  	seqID=consts.long_min;
	  	moneySeqID=consts.long_min;
	  	commoditySeqID=consts.long_min;
	  	commodityID="";
	  	commodityName="";
	  	salePrice=consts.double_min;
	  	saleAmount=consts.double_min;
	  	storagePrice=consts.double_min;
	  	specialOffer=consts.int_min;
	  	userID="";
	  	cashboxNO=consts.long_min;
	  	memberSeqID="";
	  	saleTime=DateTime.Now;
	  	settleState=consts.int_min;
	  	saleType=DEFAULT;
	  // dao=(HsaleDao)SpringContext.Context.GetObject("HsaleDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("moneySeqID", @"销售号");
		colNames.Add("moneySeqID");
		m_colLabels.Add("commoditySeqID", @"商品序号");
		colNames.Add("commoditySeqID");
		m_colLabels.Add("commodityID", @"商品条形码");
		colNames.Add("commodityID");
		m_colLabels.Add("commodityName", @"商品名称");
		colNames.Add("commodityName");
		m_colLabels.Add("salePrice", @"单价");
		colNames.Add("salePrice");
		m_colLabels.Add("saleAmount", @"数量");
		colNames.Add("saleAmount");
		m_colLabels.Add("storagePrice", @"库存均价");
		colNames.Add("storagePrice");
		m_colLabels.Add("specialOffer", @"状态");
		colNames.Add("specialOffer");
		m_enum_specialOffer= new Hashtable();
		m_enum_specialOffer.Add("11", @"特价");
		m_enum_specialOffer.Add("10", @"普通");
		m_colLabels.Add("userID", @"收银员");
		colNames.Add("userID");
		m_colLabels.Add("cashboxNO", @"钱箱");
		colNames.Add("cashboxNO");
		m_colLabels.Add("memberSeqID", @"会员编号");
		colNames.Add("memberSeqID");
		m_colLabels.Add("saleTime", @"销售时间");
		colNames.Add("saleTime");
		m_colLabels.Add("settleState", @"结算状态");
		colNames.Add("settleState");
		m_enum_settleState= new Hashtable();
		m_enum_settleState.Add("1", @"已结算");
		m_enum_settleState.Add("0", @"未结算");
		m_colLabels.Add("saleType", @"销售类型");
		colNames.Add("saleType");
		m_enum_saleType= new Hashtable();
		m_enum_saleType.Add("0", @"销售");
		m_enum_saleType.Add("1", @"退货");
		m_enum_saleType.Add("2", @"损耗");
	  }
	
	}
	public t_hsale(Hsale entity )
	{
		__hsale=entity;
		
	  // dao=(HsaleDao)SpringContext.Context.GetObject("HsaleDao");
	   if(m_colLabels==null)
	   {
		m_colLabels = new Hashtable();
        m_colNames= new ArrayList();
		m_colLabels.Add("seqID", @"编号");
		colNames.Add("seqID");
		m_colLabels.Add("moneySeqID", @"销售号");
		colNames.Add("moneySeqID");
		m_colLabels.Add("commoditySeqID", @"商品序号");
		colNames.Add("commoditySeqID");
		m_colLabels.Add("commodityID", @"商品条形码");
		colNames.Add("commodityID");
		m_colLabels.Add("commodityName", @"商品名称");
		colNames.Add("commodityName");
		m_colLabels.Add("salePrice", @"单价");
		colNames.Add("salePrice");
		m_colLabels.Add("saleAmount", @"数量");
		colNames.Add("saleAmount");
		m_colLabels.Add("storagePrice", @"库存均价");
		colNames.Add("storagePrice");
		m_colLabels.Add("specialOffer", @"状态");
		colNames.Add("specialOffer");
		m_enum_specialOffer= new Hashtable();
		m_enum_specialOffer.Add("11", @"特价");
		m_enum_specialOffer.Add("10", @"普通");
		m_colLabels.Add("userID", @"收银员");
		colNames.Add("userID");
		m_colLabels.Add("cashboxNO", @"钱箱");
		colNames.Add("cashboxNO");
		m_colLabels.Add("memberSeqID", @"会员编号");
		colNames.Add("memberSeqID");
		m_colLabels.Add("saleTime", @"销售时间");
		colNames.Add("saleTime");
		m_colLabels.Add("settleState", @"结算状态");
		colNames.Add("settleState");
		m_enum_settleState= new Hashtable();
		m_enum_settleState.Add("1", @"已结算");
		m_enum_settleState.Add("0", @"未结算");
		m_colLabels.Add("saleType", @"销售类型");
		colNames.Add("saleType");
		m_enum_saleType= new Hashtable();
		m_enum_saleType.Add("0", @"销售");
		m_enum_saleType.Add("1", @"退货");
		m_enum_saleType.Add("2", @"损耗");
	  }
	
	}
	public Object uniqueResult(DetachedCriteria dc)
    {
        return dao.uniqueResult(dc);
    }
	 public DetachedCriteria DC 
     {
        	get{return DetachedCriteria.For(typeof(Hsale));}
     }
	public const string ENTITYNAME="t_hsale";
	public const int SEQN0=151;
	
    public void checkAdd()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	//try{Convert.ToInt64(moneySeqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}

	//try{Convert.ToInt64(commoditySeqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	commoditySeqID<consts.long_min+1)
			throw (new Exception("请输入商品序号"));

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条形码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条形码不能为空!"));	
	

	
	len=commodityName.Trim().Length;
	if(len>50)
		 throw (new Exception("商品名称字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品名称不能为空!"));	
	

	//try{Convert.ToDouble(salePrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	salePrice<consts.double_min+1)
			throw (new Exception("请输入单价"));
		if(salePrice>0)
			salePrice+=0.000001;
		if(salePrice<0)
			salePrice-=0.000001;
		
			if(((long)((salePrice)*100 ))*10!=(long)((salePrice)*1000) )
				throw (new Exception("单价小数精度不能大于2位salePrice="+salePrice.ToString()));
		if(salePrice>0)
			salePrice-=0.000001;
		if(salePrice<0)
			salePrice+=0.000001;
	

	//try{Convert.ToDouble(saleAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	saleAmount<consts.double_min+1)
			throw (new Exception("请输入数量"));
		if(saleAmount>0)
			saleAmount+=0.000001;
		if(saleAmount<0)
			saleAmount-=0.000001;
		
			if(((long)((saleAmount)*100 ))*10!=(long)((saleAmount)*1000) )
				throw (new Exception("数量小数精度不能大于2位saleAmount="+saleAmount.ToString()));
		if(saleAmount>0)
			saleAmount-=0.000001;
		if(saleAmount<0)
			saleAmount+=0.000001;
	

	//try{Convert.ToDouble(storagePrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	storagePrice<consts.double_min+1)
			throw (new Exception("请输入库存均价"));
		if(storagePrice>0)
			storagePrice+=0.000001;
		if(storagePrice<0)
			storagePrice-=0.000001;
		
			if(((long)((storagePrice)*10000 ))*10!=(long)((storagePrice)*100000) )
				throw (new Exception("库存均价小数精度不能大于4位storagePrice="+storagePrice.ToString()));
		if(storagePrice>0)
			storagePrice-=0.000001;
		if(storagePrice<0)
			storagePrice+=0.000001;
	

	//try{Convert.ToInt32(specialOffer);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	specialOffer<consts.int_min+1)
			throw (new Exception("请输入状态"));

	
	len=userID.Trim().Length;
	if(len>20)
		 throw (new Exception("收银员字符长度最长不能超过20,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("收银员不能为空!"));	
	

	//try{Convert.ToInt64(cashboxNO);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	cashboxNO<consts.long_min+1)
			throw (new Exception("请输入钱箱"));

	
	len=memberSeqID.Trim().Length;
	if(len>50)
		 throw (new Exception("会员编号字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDateTime(saleTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	saleTime.ToString().CompareTo(consts.datetime_min) <= 0 )
			throw (new Exception("请输入销售时间"));

	//try{Convert.ToInt32(settleState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	settleState<consts.int_min+1)
			throw (new Exception("请输入结算状态"));

	//try{Convert.ToInt32(saleType);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	saleType<consts.int_min+1)
			throw (new Exception("请输入销售类型"));

//unique="yes" 唯一性验证
    }
    public void checkUpdate()
    {
		int len;
	//try{Convert.ToInt64(seqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	seqID<consts.long_min+1)
			throw (new Exception("请输入编号"));
 if(				(				  string.Format("{0}",seqID)				  )=="0")
	 throw (new Exception("编号是主健，框架要求值不能为0"));				

	//try{Convert.ToInt64(moneySeqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}

	//try{Convert.ToInt64(commoditySeqID);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	commoditySeqID<consts.long_min+1)
			throw (new Exception("请输入商品序号"));

	
	len=commodityID.Trim().Length;
	if(len>50)
		 throw (new Exception("商品条形码字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品条形码不能为空!"));	
	

	
	len=commodityName.Trim().Length;
	if(len>50)
		 throw (new Exception("商品名称字符长度最长不能超过50,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("商品名称不能为空!"));	
	

	//try{Convert.ToDouble(salePrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	salePrice<consts.double_min+1)
			throw (new Exception("请输入单价"));
		if(salePrice>0)
			salePrice+=0.000001;
		if(salePrice<0)
			salePrice-=0.000001;
		
			if(((long)((salePrice)*100 ))*10!=(long)((salePrice)*1000) )
				throw (new Exception("单价小数精度不能大于2位salePrice="+salePrice.ToString()));
		if(salePrice>0)
			salePrice-=0.000001;
		if(salePrice<0)
			salePrice+=0.000001;
	

	//try{Convert.ToDouble(saleAmount);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	saleAmount<consts.double_min+1)
			throw (new Exception("请输入数量"));
		if(saleAmount>0)
			saleAmount+=0.000001;
		if(saleAmount<0)
			saleAmount-=0.000001;
		
			if(((long)((saleAmount)*100 ))*10!=(long)((saleAmount)*1000) )
				throw (new Exception("数量小数精度不能大于2位saleAmount="+saleAmount.ToString()));
		if(saleAmount>0)
			saleAmount-=0.000001;
		if(saleAmount<0)
			saleAmount+=0.000001;
	

	//try{Convert.ToDouble(storagePrice);}catch{ throw (new Exception("请输入正确的小数格式"));		}
		if(	storagePrice<consts.double_min+1)
			throw (new Exception("请输入库存均价"));
		if(storagePrice>0)
			storagePrice+=0.000001;
		if(storagePrice<0)
			storagePrice-=0.000001;
		
			if(((long)((storagePrice)*10000 ))*10!=(long)((storagePrice)*100000) )
				throw (new Exception("库存均价小数精度不能大于4位storagePrice="+storagePrice.ToString()));
		if(storagePrice>0)
			storagePrice-=0.000001;
		if(storagePrice<0)
			storagePrice+=0.000001;
	

	//try{Convert.ToInt32(specialOffer);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	specialOffer<consts.int_min+1)
			throw (new Exception("请输入状态"));

	
	len=userID.Trim().Length;
	if(len>20)
		 throw (new Exception("收银员字符长度最长不能超过20,当前长度为"+len.ToString()));	
	else if(len==0)
		throw (new Exception("收银员不能为空!"));	
	

	//try{Convert.ToInt64(cashboxNO);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	cashboxNO<consts.long_min+1)
			throw (new Exception("请输入钱箱"));

	
	len=memberSeqID.Trim().Length;
	if(len>50)
		 throw (new Exception("会员编号字符长度最长不能超过50,当前长度为"+len.ToString()));	
	

	//try{Convert.ToDateTime(saleTime);}catch{ throw (new Exception("请输入正确的长整数格式"));		}
		if(	saleTime.ToString().CompareTo(consts.datetime_min) <= 0 )
			throw (new Exception("请输入销售时间"));

	//try{Convert.ToInt32(settleState);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	settleState<consts.int_min+1)
			throw (new Exception("请输入结算状态"));

	//try{Convert.ToInt32(saleType);}catch{ throw (new Exception("请输入正确的整数格式"));		}
		if(	saleType<consts.int_min+1)
			throw (new Exception("请输入销售类型"));

//unique="yes" 唯一性验证
		ICriterion crit=Restrictions.Eq("seqID", seqID);
  		IList list=dao.List(dao.DC.Add(crit));
		if(list.Count==1)
			return;
		if(list.Count==0)
			throw (new Exception("该记录已经被删除"));	
		else
			throw (new Exception("改纪录出现重名!"));
    }
    public void add()
    {
        try
        {
            checkAdd();
         	dao.Add(__hsale);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void delByseqID()
    {
    
        try
        {
          dao.Delete(__hsale);
        }
        catch(Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }

    public  void update()
    {
        try
        {
            checkUpdate();
            dao.Update(__hsale);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
   
    public void ExecDataUpdate(int rowNo)
    {
		if(m_updateRow==null)
			return;
		int ii=0;
m_updateRow(rowNo,ii++,				(				  string.Format("{0}",seqID)				  ));	
m_updateRow(rowNo,ii++,commodityID);	
m_updateRow(rowNo,ii++,commodityName);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",salePrice)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F2}",saleAmount)/***/)
);	
m_updateRow(rowNo,ii++,/***/(						string.Format("{0:F4}",storagePrice)/***/)
);	
m_updateRow(rowNo,ii++,	t_hsale.enum_specialOffer[specialOffer.ToString()].ToString()
);	
m_updateRow(rowNo,ii++,userID);	
m_updateRow(rowNo,ii++,				(				  string.Format("{0}",cashboxNO)				  ));	
m_updateRow(rowNo,ii++,			saleTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",saleTime));	

    }
    public void ExecHeadInsert()
    {
		if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,60,"编号");
			m_insertHead(ii++,200,"商品条形码");
			m_insertHead(ii++,200,"商品名称");
			m_insertHead(ii++,100,"单价");
			m_insertHead(ii++,100,"数量");
			m_insertHead(ii++,100,"库存均价");
			m_insertHead(ii++,100,"状态");
			m_insertHead(ii++,30,"收银员");
			m_insertHead(ii++,30,"钱箱");
			m_insertHead(ii++,100,"销售时间");
		}		
    }
    public void ExecDataInsert()
	{
		if(m_insertRow==null)
			return;
		int ii=0;
     	m_insertRow(0,ii++,				(				  string.Format("{0}",seqID)				  ));
     	m_insertRow(0,ii++,commodityID);
     	m_insertRow(0,ii++,commodityName);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",salePrice)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F2}",saleAmount)/***/)
);
     	m_insertRow(0,ii++,/***/(						string.Format("{0:F4}",storagePrice)/***/)
);
     	m_insertRow(0,ii++,	t_hsale.enum_specialOffer[specialOffer.ToString()].ToString()
);
     	m_insertRow(0,ii++,userID);
     	m_insertRow(0,ii++,				(				  string.Format("{0}",cashboxNO)				  ));
     	m_insertRow(0,ii++,			saleTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",saleTime));
    }
    public void ExecDataInsertByQuery(DetachedCriteria dc)
    {
      
         IList list=dao.List(dc); 
        
        if(m_insertHead!=null)
        {
			int ii=0;
			m_insertHead(ii++,60,"编号");
			m_insertHead(ii++,200,"商品条形码");
			m_insertHead(ii++,200,"商品名称");
			m_insertHead(ii++,100,"单价");
			m_insertHead(ii++,100,"数量");
			m_insertHead(ii++,100,"库存均价");
			m_insertHead(ii++,100,"状态");
			m_insertHead(ii++,30,"收银员");
			m_insertHead(ii++,30,"钱箱");
			m_insertHead(ii++,100,"销售时间");
		}		
		
      if(m_insertRow!=null)
      {
        int j=0;
        foreach(Hsale obj in list)			
        {
		  int ii=0;
	     
m_insertRow(j,ii++,				(				  string.Format("{0}",obj.seqID)
				  )
);
m_insertRow(j,ii++,obj.commodityID.ToString());
m_insertRow(j,ii++,obj.commodityName.ToString());
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.salePrice)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F2}",obj.saleAmount)
					)
);
m_insertRow(j,ii++,(					string.Format("{0:F4}",obj.storagePrice)
					)
);
m_insertRow(j,ii++,	t_hsale.enum_specialOffer[obj.specialOffer.ToString()].ToString()
);
m_insertRow(j,ii++,obj.userID.ToString());
m_insertRow(j,ii++,				(				  string.Format("{0}",obj.cashboxNO)
				  )
);
m_insertRow(j,ii++,			obj.saleTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",obj.saleTime)
);
		j++;
        }
        

	
       }
    }

    
    public IList List(DetachedCriteria dc)
    {
        try
        {
           
            return dao.List(dc);
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
        }
    }
    
    public bool Init(DetachedCriteria dc)
    {
    
    		Hsale obj=dao.Get(dc);
    		if(obj==null)
    			return false;
    		else
    		{
    			__hsale=obj;
            	return true;
            }
        
    }
    public static t_hsale Get(DetachedCriteria dc)
    {
    	
    	Hsale obj=((HsaleDao)SpringContext.Context.GetObject("HsaleDao"))
	 	.Get(dc);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_hsale( obj );
        
    }
	 public static t_hsale GetBySeqID(long val)
	 {
	 	Hsale obj=((HsaleDao)SpringContext.Context.GetObject("HsaleDao"))
	 	.GetBySeqID(val);
	 	if(obj==null)
	 		return null;
	 	else
	 		return new t_hsale( obj );
	 	
	 	
	 }
	 public  bool InitBySeqID(long val)
	 {
	 	

	 	Hsale obj=dao.GetBySeqID(val) ;
	 	if(obj==null)
	 		return false;
	 	else
	 	{
	 		__hsale=obj;
	 		return true;
	 	}
	 	
	 	
	 }
    
       public bool showInForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			Controls["seqID"].Text=				(				  string.Format("{0}",seqID)				  );
		}
		if(Controls["moneySeqID"]!=null)
		{
			Controls["moneySeqID"].Text=				(				  Convert.ToInt32(string.Format("{0}",moneySeqID))<(consts.int_min+1)?"":string.Format("{0}",moneySeqID));
		}
		if(Controls["commoditySeqID"]!=null)
		{
			Controls["commoditySeqID"].Text=				(				  string.Format("{0}",commoditySeqID)				  );
		}
		if(Controls["commodityID"]!=null)
		{
			Controls["commodityID"].Text=commodityID;
		}
		if(Controls["commodityName"]!=null)
		{
			Controls["commodityName"].Text=commodityName;
		}
		if(Controls["salePrice"]!=null)
		{
			Controls["salePrice"].Text=/***/(						string.Format("{0:F2}",salePrice)/***/)
;
		}
		if(Controls["saleAmount"]!=null)
		{
			Controls["saleAmount"].Text=/***/(						string.Format("{0:F2}",saleAmount)/***/)
;
		}
		if(Controls["storagePrice"]!=null)
		{
			Controls["storagePrice"].Text=/***/(						string.Format("{0:F4}",storagePrice)/***/)
;
		}
		if(Controls["specialOffer"]!=null)
		{
			Controls["specialOffer"].Text=	t_hsale.enum_specialOffer[specialOffer.ToString()].ToString()
;
		}
		if(Controls["userID"]!=null)
		{
			Controls["userID"].Text=userID;
		}
		if(Controls["cashboxNO"]!=null)
		{
			Controls["cashboxNO"].Text=				(				  string.Format("{0}",cashboxNO)				  );
		}
		if(Controls["memberSeqID"]!=null)
		{
			Controls["memberSeqID"].Text=memberSeqID;
		}
		if(Controls["saleTime"]!=null)
		{
			Controls["saleTime"].Text=			saleTime.ToString().CompareTo("1001-1-1")<0?"":string.Format("{0:g}",saleTime);
		}
		if(Controls["settleState"]!=null)
		{
			Controls["settleState"].Text=	t_hsale.enum_settleState[settleState.ToString()].ToString()
;
		}
		if(Controls["saleType"]!=null)
		{
			Controls["saleType"].Text=	t_hsale.enum_saleType[saleType.ToString()].ToString()
;
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    public  t_hsale Init(Hsale item)
    {
        __hsale=item;
        return this;
    }

    
     public bool initByForm(Control.ControlCollection Controls)
    {
        try
        {
             
		if(Controls["seqID"]!=null)
		{
			
			if(Controls["seqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["seqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{seqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
			else
			{
				try{seqID=(Controls["seqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["seqID"].Text));}
				catch
				{
					 Controls["seqID"].Focus();
					throw  (new Exception("编号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["moneySeqID"]!=null)
		{
			
			if(Controls["moneySeqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["moneySeqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{moneySeqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["moneySeqID"].Focus();
					throw  (new Exception("销售号格式不正确！！"));
				}
				
			}
			else
			{
				try{moneySeqID=(Controls["moneySeqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["moneySeqID"].Text));}
				catch
				{
					 Controls["moneySeqID"].Focus();
					throw  (new Exception("销售号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commoditySeqID"]!=null)
		{
			
			if(Controls["commoditySeqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commoditySeqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commoditySeqID=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["commoditySeqID"].Focus();
					throw  (new Exception("商品序号格式不正确！！"));
				}
				
			}
			else
			{
				try{commoditySeqID=(Controls["commoditySeqID"].Text==""?consts.long_min:Convert.ToInt32(Controls["commoditySeqID"].Text));}
				catch
				{
					 Controls["commoditySeqID"].Focus();
					throw  (new Exception("商品序号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityID"]!=null)
		{
			
			if(Controls["commodityID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityID=v;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条形码格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityID=Controls["commodityID"].Text;}
				catch
				{
					 Controls["commodityID"].Focus();
					throw  (new Exception("商品条形码格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["commodityName"]!=null)
		{
			
			if(Controls["commodityName"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["commodityName"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{commodityName=v;}
				catch
				{
					 Controls["commodityName"].Focus();
					throw  (new Exception("商品名称格式不正确！！"));
				}
				
			}
			else
			{
				try{commodityName=Controls["commodityName"].Text;}
				catch
				{
					 Controls["commodityName"].Focus();
					throw  (new Exception("商品名称格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["salePrice"]!=null)
		{
			
			if(Controls["salePrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["salePrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{salePrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["salePrice"].Focus();
					throw  (new Exception("单价格式不正确！！"));
				}
				
			}
			else
			{
				try{salePrice=(Controls["salePrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["salePrice"].Text));}
				catch
				{
					 Controls["salePrice"].Focus();
					throw  (new Exception("单价格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["saleAmount"]!=null)
		{
			
			if(Controls["saleAmount"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["saleAmount"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{saleAmount=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["saleAmount"].Focus();
					throw  (new Exception("数量格式不正确！！"));
				}
				
			}
			else
			{
				try{saleAmount=(Controls["saleAmount"].Text==""?consts.double_min:Convert.ToDouble(Controls["saleAmount"].Text));}
				catch
				{
					 Controls["saleAmount"].Focus();
					throw  (new Exception("数量格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["storagePrice"]!=null)
		{
			
			if(Controls["storagePrice"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["storagePrice"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{storagePrice=(v==""?consts.double_min:Convert.ToDouble(v));}
				catch
				{
					 Controls["storagePrice"].Focus();
					throw  (new Exception("库存均价格式不正确！！"));
				}
				
			}
			else
			{
				try{storagePrice=(Controls["storagePrice"].Text==""?consts.double_min:Convert.ToDouble(Controls["storagePrice"].Text));}
				catch
				{
					 Controls["storagePrice"].Focus();
					throw  (new Exception("库存均价格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["specialOffer"]!=null)
		{
			
			if(Controls["specialOffer"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["specialOffer"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{specialOffer=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["specialOffer"].Focus();
					throw  (new Exception("状态格式不正确！！"));
				}
				
			}
			else
			{
				try{specialOffer=(Controls["specialOffer"].Text==""?consts.int_min:Convert.ToInt32(Controls["specialOffer"].Text));}
				catch
				{
					 Controls["specialOffer"].Focus();
					throw  (new Exception("状态格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["userID"]!=null)
		{
			
			if(Controls["userID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["userID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{userID=v;}
				catch
				{
					 Controls["userID"].Focus();
					throw  (new Exception("收银员格式不正确！！"));
				}
				
			}
			else
			{
				try{userID=Controls["userID"].Text;}
				catch
				{
					 Controls["userID"].Focus();
					throw  (new Exception("收银员格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["cashboxNO"]!=null)
		{
			
			if(Controls["cashboxNO"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["cashboxNO"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{cashboxNO=(v==""?consts.long_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["cashboxNO"].Focus();
					throw  (new Exception("钱箱格式不正确！！"));
				}
				
			}
			else
			{
				try{cashboxNO=(Controls["cashboxNO"].Text==""?consts.long_min:Convert.ToInt32(Controls["cashboxNO"].Text));}
				catch
				{
					 Controls["cashboxNO"].Focus();
					throw  (new Exception("钱箱格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["memberSeqID"]!=null)
		{
			
			if(Controls["memberSeqID"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["memberSeqID"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{memberSeqID=v;}
				catch
				{
					 Controls["memberSeqID"].Focus();
					throw  (new Exception("会员编号格式不正确！！"));
				}
				
			}
			else
			{
				try{memberSeqID=Controls["memberSeqID"].Text;}
				catch
				{
					 Controls["memberSeqID"].Focus();
					throw  (new Exception("会员编号格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["saleTime"]!=null)
		{
			
			if(Controls["saleTime"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["saleTime"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{saleTime=(v==""?new DateTime(1000,1,1):Convert.ToDateTime(v));}
				catch
				{
					 Controls["saleTime"].Focus();
					throw  (new Exception("销售时间格式不正确！！"));
				}
				
			}
			else
			{
				try{saleTime=(Controls["saleTime"].Text==""?new DateTime(1000,1,1):Convert.ToDateTime(Controls["saleTime"].Text));}
				catch
				{
					 Controls["saleTime"].Focus();
					throw  (new Exception("销售时间格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["settleState"]!=null)
		{
			
			if(Controls["settleState"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["settleState"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{settleState=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["settleState"].Focus();
					throw  (new Exception("结算状态格式不正确！！"));
				}
				
			}
			else
			{
				try{settleState=(Controls["settleState"].Text==""?consts.int_min:Convert.ToInt32(Controls["settleState"].Text));}
				catch
				{
					 Controls["settleState"].Focus();
					throw  (new Exception("结算状态格式不正确！！"));
				}
				
			}
				
				
		}
		if(Controls["saleType"]!=null)
		{
			
			if(Controls["saleType"].GetType().Name=="ComboBox")
			{
				ComboBox box=(ComboBox)Controls["saleType"];
				
				string v=box.SelectedValue==null?box.Text:Convert.ToString(box.SelectedValue);
				try{saleType=(v==""?consts.int_min:Convert.ToInt32(v));}
				catch
				{
					 Controls["saleType"].Focus();
					throw  (new Exception("销售类型格式不正确！！"));
				}
				
			}
			else
			{
				try{saleType=(Controls["saleType"].Text==""?consts.int_min:Convert.ToInt32(Controls["saleType"].Text));}
				catch
				{
					 Controls["saleType"].Focus();
					throw  (new Exception("销售类型格式不正确！！"));
				}
				
			}
				
				
		}
			return true;
        }
        catch (Exception ex)
        {
            throw (new Exception(ex.Message));
            
        }
    }
    

}

}
